part of '../fhare.dart';

class DataWidget<T> extends InheritedWidget {
  final T data;

  DataWidget({required super.child, required this.data}) : super(key: UniqueKey());

  @override
  bool updateShouldNotify(DataWidget oldWidget) {
    return data == oldWidget.data;
  }

  static T? dataOf<T>(BuildContext context) {
    DataWidget<T>? w = context.dependOnInheritedWidgetOfExactType<DataWidget<T>>();
    return w?.data;
  }
}

//HareApp.run(DataWidget(child: UseDataPage(), data: "Entao"));
// class UseDataPage extends HareWidget {
//   UseDataPage() : super();
//
//   @override
//   Widget build(BuildContext context) {
//     String? s = DataWidget.dataOf(context);
//     return "Hello $s".text().centered().sized(width: 800, height: 800).coloredBox(Colors.cyan);
//   }
// }
